var rootPath = getRootPath();
$(function() {
$.ajax({
	url : rootPath + '/listAllTitle',
	type : 'POST',
	contentType : 'application/json',
	dataType : 'json',
	success : function(data) {
		console.log(data)
		help_show(data);
	},
	error : function(jqXHR, textStatus, errorThrown) {
		layer.alert("error:(");
	}
});

});

function help_show(data){
	if(data.state=="1"){
		var length = data.dataObject.length;
		var tr;
		for (var i = 0; i < length; i++) {
	tr += "<tr class='text-c' id='help_" + data.dataObject[i].id +"' name='helpTr'>";
	tr += "<td>" + data.dataObject[i].id + "</td>";
	tr += "<td>" + data.dataObject[i].productid + "</td>";
	tr += "<td>" + data.dataObject[i].name + "</td>";	
	if(data.dataObject[i].sort=="1"){
		tr += "<td>运营服务</td>";
	}else{
		tr += "<td>产品操作</td>";
	}
	tr += "<td>" + data.dataObject[i].time + "</td>";	
	tr += "<td>" 
	tr += "<a title='编辑' href='javascript:;' onclick='help_add_edit(\"编辑模块\","
		+ "\"helpEditPage?uid="+ data.dataObject[i].id
		+ "\", \"\",\"\",\"\")' style='text-decoration:none'><i class='iconfont marginLeft12'>&#xe60a;</i></a>";                               
tr += "<a title='删除' href='javascript:;' onclick='help_del(this,"
		+ "\""
		+  data.dataObject[i].id
		+ "\")' class='ml-5' style='text-decoration:none'><i class='iconfont marginLeft12'>&#xe612;</i></a>"+ "</td></tr>";	
		
		}
		$("#helpmodule").empty();
		$("#helpmodule").append(tr);
	}
	
}

function help_del(data,id){
	
	$.ajax({
		url : rootPath + '/deleteproduct',
		type : 'POST',
		data:{
			'id':id
		},
		success : function(data) {
			layer.msg('成功',{icon:1,time:1000},function() {
				window.location.href = rootPath + '/helpPage';				
			});
		},
		error : function(jqXHR, textStatus, errorThrown) {
			layer.alert("error:(");
		}
	});
}

/*管理员-帮助模块-添加-编辑*/
function help_add_edit(title,url,w,h){
	layer_show(title,url,w,h);
}





